<?php
header("Content-Type:json/html;charset=utf8;");

$config = require '../config.php';
$conn = new mysqli($config['servername'], $config['username'], $config['password'], $config['dbname']);

require "../validToken.php";
$info = isValidToken($conn);

if($info['status']){
    $sql = "select c.*,a.title from comment as c,article as a where a.id = c.article_id";
    $result = $conn->query($sql);
    $conn->close();

    $data = array();
    while ($row = $result->fetch_assoc())
    {
        $data[] = $row;
    }
    $result = ['code' =>1, 'data' => $data,  'msg' => "获取评论成功!"];
}else{
    $result = ['code' =>-1, 'msg' => "token无效!"];
}
print_r(json_encode($result));

